package org.lpw.wormhole.servlet;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.lpw.wormhole.SimpleWormholeContext;
import org.lpw.wormhole.WormholeContext;

/**
 * Wormhole环境监听器。用于对基于Servlet的Wormhole环境进行启动与销毁。
 * 
 * @author lpw
 */
public class WormholeContextListener
    implements ServletContextListener
{
    protected WormholeContext wormholeContext;

    @Override
    public void contextInitialized(ServletContextEvent sce)
    {
        wormholeContext = new SimpleWormholeContext();
        wormholeContext.initialize();
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce)
    {
        wormholeContext.destory();
    }
}
